import urllib

import peres
import genny

from genny.wave_rendering import render_blip_part_with_new_text

class SimpleGoogleSearchLinkRenderer(genny.renderer.Renderer):
    def __init__(self):
        super(SimpleGoogleSearchLinkRenderer, self).__init__(genny.token_filter.BasicObjectFilter([(peres.parser.SimpleObject.TYPE_LINK, "gs")]))
    
    def render(self, token):
        encoded_text =  urllib.urlencode({'': token.get_obj_value()})
        return render_blip_part_with_new_text(token, 'http://www.google.com/search?q%s' % (encoded_text))
